package com.yw.swagger.tool.Utils;

import com.yw.swagger.service.AuthorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.security.SecureRandom;
import java.util.Random;

/**
 * @Author: Abeiv
 * @Description: 权限码
 * @Date: 2019/10/26 10:55
 */
@Component
public class AuthorUtils {
    @Autowired
    private AuthorService authorService;
    /**
     * 生成权限码
     * @return
     */
    public static String getAuthor(int len){
        String[] arr = "a,b,c,d,e,f,j,h,i,g,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,0,1,2,3,4,5,6,7,8,9".split(",");
        StringBuffer sbf = new StringBuffer();
        Random random = new SecureRandom();
        for (int i = 0; i < len; i++){
            sbf.append(arr[random.nextInt(36)]);
        }
        return  sbf.toString();
    }

}
